package cn.thoughtworks.school.controllers;

import cn.thoughtworks.school.entities.Event;
import cn.thoughtworks.school.entities.PV;
import cn.thoughtworks.school.services.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/collections")
public class ActivityController {
  @Autowired
  private ActivityService activityService;

  @PostMapping("pv")
  public ResponseEntity pv(@RequestBody PV pv) {
    activityService.savePv(pv);
    return new ResponseEntity(HttpStatus.CREATED);
  }


  @PostMapping("events")
  public ResponseEntity events(@RequestBody Event event) {
    activityService.saveEvent(event);
    return new ResponseEntity(HttpStatus.CREATED);
  }

}
